home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / moden / adstatlt.int < prev    next >
Text File  |  1996-04-08  |  8KB  |  249 lines

  1. {$G+,X+,F+}
  2.  
  3. {Conditional defines that may affect this unit}
  4. {$I AWDEFINE.INC}
  5.  
  6. {*********************************************************}
  7. {*                  ADSTATLT.PAS 1.01                    *}
  8. {*        Copyright (c) TurboPower Software 1995         *}
  9. {*                 All rights reserved.                  *}
  10. {*********************************************************}
  11.  
  12. unit AdStatLt;
  13.   {-Port status light component}
  14.  
  15. interface
  16.  
  17. uses
  18.   {------RTL}
  19.   WinTypes,
  20.   WinProcs,
  21.   SysUtils,
  22.   Classes,
  23.   Controls,
  24.   Graphics,
  25.   Forms,
  26.   {------APD}
  27.   Dialogs,
  28.   OoMisc,
  29.   AdPort;
  30.  
  31. const
  32.   DefLightDim = 13;
  33.  
  34. const
  35.   DefErrorOffTimeout = 36;
  36.   DefBreakOffTimeout = 36;
  37.   DefRXDOffTimeout   = 1;
  38.   DefTXDOffTimeout   = 1;
  39.   DefRingOffTimeout  = 8;
  40.   DefLitColor        = clRed;
  41.   DefNotLitColor     = clGreen;
  42.  
  43. type
  44.   TApdCustomStatusLight = class(TGraphicControl)
  45.   protected {private}
  46.     {.Z+}
  47.     FGlyph       : TBitmap;
  48.     FLit         : Boolean;
  49.     FLitColor    : TColor;
  50.     FNotLitColor : TColor;
  51.     HaveGlyph    : Boolean;
  52.  
  53.     procedure SetGlyph(const NewGlyph : TBitmap);
  54.       {-Set the bitmap displayed for the light}
  55.     procedure SetLit(const IsLit : Boolean);
  56.       {-Set whether the light is lit or not}
  57.     procedure SetLitColor(const NewColor : TColor);
  58.       {-Set the color the light is displayed in when it is lit}
  59.     procedure SetNotLitColor(const NewColor : TColor);
  60.       {-Set the color the light is displayed in when it is not lit}
  61.  
  62.     procedure SetBounds(ALeft, ATop, AWidth, AHeight : Integer); override;
  63.     procedure Paint; override;
  64.     procedure Loaded; override;
  65.  
  66.   public
  67.     constructor Create(AOwner : TComponent); override;
  68.     destructor Destroy; override;
  69.     {.Z-}
  70.  
  71.     property Glyph : TBitmap
  72.       read FGlyph write SetGlyph;
  73.     property Lit : Boolean
  74.       read FLit write SetLit;
  75.     property LitColor : TColor
  76.       read FLitColor write SetLitColor default DefLitColor;
  77.     property NotLitColor : TColor
  78.       read FNotLitColor write SetNotLitColor default DefNotLitColor;
  79.   end;
  80.  
  81.   TApdStatusLight = class(TApdCustomStatusLight)
  82.   published
  83.     property Glyph;
  84.     property Lit;
  85.     property LitColor;
  86.     property NotLitColor;
  87.   end;
  88.  
  89.   TLightSet = class(TPersistent)
  90.   protected {private}
  91.     {.Z+}
  92.     FCTSLight   : TApdCustomStatusLight;
  93.     FDSRLight   : TApdCustomStatusLight;
  94.     FDCDLight   : TApdCustomStatusLight;
  95.     FRINGLight  : TApdCustomStatusLight;
  96.     FTXDLight   : TApdCustomStatusLight;
  97.     FRXDLight   : TApdCustomStatusLight;
  98.     FERRORLight : TApdCustomStatusLight;
  99.     FBREAKLight : TApdCustomStatusLight;
  100.  
  101.   public
  102.     constructor Create;
  103.     {.Z-}
  104.  
  105.     procedure InitLights(const ComPort : TApdCustomComPort);
  106.  
  107.   published
  108.     property CTSLight : TApdCustomStatusLight
  109.       read FCTSLight write FCTSLight;
  110.     property DSRLight : TApdCustomStatusLight
  111.       read FDSRLight write FDSRLight;
  112.     property DCDLight : TApdCustomStatusLight
  113.       read FDCDLight write FDCDLight;
  114.     property RINGLight : TApdCustomStatusLight
  115.       read FRINGLight write FRINGLight;
  116.     property TXDLight : TApdCustomStatusLight
  117.       read FTXDLight write FTXDLight;
  118.     property RXDLight : TApdCustomStatusLight
  119.       read FRXDLight write FRXDLight;
  120.     property ERRORLight : TApdCustomStatusLight
  121.       read FERRORLight write FERRORLight;
  122.     property BREAKLight : TApdCustomStatusLight
  123.       read FBREAKLight write FBREAKLight;
  124.   end;
  125.  
  126.   TApdCustomSLController = class(TComponent)
  127.   protected {private}
  128.     {.Z+}
  129.     {port stuff}
  130.     FComPort          : TApdCustomComPort;
  131.     FMonitoring       : Boolean;
  132.  
  133.     {timeouts}
  134.     FErrorOffTimeout  : LongInt;
  135.     FBreakOffTimeout  : LongInt;
  136.     FRXDOffTimeout    : LongInt;
  137.     FTXDOffTimeout    : LongInt;
  138.     FRingOffTimeout   : LongInt;
  139.  
  140.     {lights}
  141.     FLights           : TLightSet;
  142.  
  143.     {saved event handlers}
  144.     SaveTriggerAvail  : TTriggerAvailEvent;   {Old data available trigger}
  145.     SaveTriggerStatus : TTriggerStatusEvent;  {Old status trigger handler}
  146.     SaveTriggerTimer  : TTriggerTimerEvent;   {Old timer trigger handler}
  147.  
  148.     {trigger handles}
  149.     ModemStatMask     : Word;                 {Status bits we want to watch}
  150.     MSTrig            : Integer;              {Modem status indicator trigger}
  151.     ErrorOnTrig       : Integer;              {ERROR indicator turn on trigger}
  152.     BreakOnTrig       : Integer;              {BREAK indicator turn on trigger}
  153.     ErrorOffTrig      : Integer;              {ERROR indicator turn off trigger}
  154.     BreakOffTrig      : Integer;              {BREAK indicator turn off trigger}
  155.     RxdOffTrig        : Integer;              {RXD indicator turn off trigger}
  156.     TxdOnTrig         : Integer;              {TXD indicator turn on trigger}
  157.     TxdOffTrig        : Integer;              {TXD indicator turn off trigger}
  158.     RingOffTrig       : Integer;              {RING indicator turn off trigger}
  159.  
  160.     function GetHaveCTSLight : Boolean;
  161.     function GetHaveDSRLight : Boolean;
  162.     function GetHaveDCDLight : Boolean;
  163.     function GetHaveRINGLight : Boolean;
  164.     function GetHaveTXDLight : Boolean;
  165.     function GetHaveRXDLight : Boolean;
  166.     function GetHaveERRORLight : Boolean;
  167.     function GetHaveBREAKLight : Boolean;
  168.  
  169.     procedure SetComPort(const NewPort : TApdCustomComPort);
  170.     procedure SetLights(const NewLights : TLightSet);
  171.     procedure SetMonitoring(const NewMon : Boolean);
  172.  
  173.     procedure Notification(AComponent : TComponent; Operation: TOperation); override;
  174.  
  175.     procedure InitTriggers;
  176.       {-Set trigger handles to their default values}
  177.     procedure AddTriggers;
  178.       {-Add triggers to com port}
  179.     procedure RemoveTriggers;
  180.       {-Remove triggers from com port}
  181.     procedure InitLights;
  182.       {-Initialize the default statuses of various modem lights}
  183.     procedure CheckLight(const CurStat : Boolean; const Light : TApdCustomStatusLight);
  184.       {-See if a light has changed and update it if so}
  185.  
  186.     {replacement trigger handlers}
  187.     procedure StatTriggerAvail(CP : TObject; Count : Word);
  188.     procedure StatTriggerStatus(CP : TObject; TriggerHandle : Word);
  189.     procedure StatTriggerTimer(CP : TObject; TriggerHandle : Word);
  190.     procedure StatPortClose(CP : TObject; Opening : Boolean);  {!!.01}
  191.  
  192.     property HaveCTSLight : Boolean
  193.       read GetHaveCTSLight;
  194.     property HaveDSRLight : Boolean
  195.       read GetHaveDSRLight;
  196.     property HaveDCDLight : Boolean
  197.       read GetHaveDCDLight;
  198.     property HaveRINGLight : Boolean
  199.       read GetHaveRINGLight;
  200.     property HaveTXDLight : Boolean
  201.       read GetHaveTXDLight;
  202.     property HaveRXDLight : Boolean
  203.       read GetHaveRXDLight;
  204.     property HaveERRORLight : Boolean
  205.       read GetHaveERRORLight;
  206.     property HaveBREAKLight : Boolean
  207.       read GetHaveBREAKLight;
  208.  
  209.   public
  210.     constructor Create(AOwner : TComponent); override;
  211.     destructor Destroy; override;
  212.     {.Z-}
  213.  
  214.     property Monitoring : Boolean
  215.       read FMonitoring write SetMonitoring;
  216.  
  217.     {port to monitor}
  218.     property ComPort : TApdCustomComPort
  219.       read FComPort write SetComPort;
  220.  
  221.     {timeout values}
  222.     property ErrorOffTimeout : LongInt
  223.       read FErrorOffTimeout write FErrorOffTimeout default DefErrorOffTimeout;
  224.     property BreakOffTimeout : LongInt
  225.       read FBreakOffTimeout write FBreakOffTimeout default DefBreakOffTimeout;
  226.     property RXDOffTimeout : LongInt
  227.       read FRXDOffTimeout write FRXDOffTimeout default DefRXDOffTimeout;
  228.     property TXDOffTimeout : LongInt
  229.       read FTXDOffTimeout write FTXDOffTimeout default DefTXDOffTimeout;
  230.     property RingOffTimeout : LongInt
  231.       read FRingOffTimeout write FRingOffTimeout default DefRingOffTimeout;
  232.  
  233.     {complete set of lights}
  234.     property Lights : TLightSet
  235.       read FLights write SetLights;
  236.   end;
  237.  
  238.   TApdSLController = class(TApdCustomSLController)
  239.   published
  240.     property ComPort;
  241.     property ErrorOffTimeout;
  242.     property BreakOffTimeout;
  243.     property RXDOffTimeout;
  244.     property TXDOffTimeout;
  245.     property RingOffTimeout;
  246.     property Lights;
  247.   end;
  248.  
  249.